package util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Merger<B, S> {

	public interface MergerOperator<B, S> {

		boolean equals(B b, S s);

		void operater(B b);

	}

	public void done(List<B> big, List<S> small, MergerOperator<B, S> mo) {
		for (B b : big) {
			boolean bool = true;
			for (S s : small) {
				if (mo.equals(b, s)) {
					bool = false;
					break;
				}
			}
			if (bool) {
				mo.operater(b);
			}
		}
	}

	public static class StringMergerOperator implements MergerOperator<String, String> {
		List<String> small;

		public StringMergerOperator(List<String> small) {
			super();
			this.small = small;
		}

		@Override
		public boolean equals(String b, String s) {
			return b.equals(s);
		}

		@Override
		public void operater(String b) {
			small.add(b);
		}

	}

	public static void main(String a[]) {
		List<String> b = new ArrayList<String>(Arrays.asList("a", "d", "c", "b"));
		List<String> s = new ArrayList<String>(Arrays.asList("a", "b"));
		Merger<String, String> merger = new Merger<String, String>();
		MergerOperator<String, String> mo = new StringMergerOperator(s);
		merger.done(b, s, mo);
		System.out.println(s);

	}

}
